package com.gitee.wsl.mathematics.function.active

import kotlin.math.exp


/**
 * @param
 * @DATA
 * @Author LiDaPeng
 * @Description
 */
class ELu(private val a: Float) : ActiveFunction {
    override fun function(x: Float): Float {
        return if (x > 0) {
            x
        } else {
            (a * (exp(x.toDouble()).toFloat() - 1))
        }
    }

    override fun functionG(out: Float): Float {
        return if (out > 0) {
            1f
        } else {
            out + a
        }
    }
}
